<%@page import="com.module.admin.prj.enums.PrjMonitorMonitorStatus"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="my" uri="/WEB-INF/tld/my.tld" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>${projectName}-今日接口请求统计</title>
<jsp:include page="/WEB-INF/view/inc/css.jsp"></jsp:include>
</head>
<body>
	<jsp:include page="/WEB-INF/view/inc/header.jsp"></jsp:include>
	<div class="container">
		<jsp:include page="/WEB-INF/view/admin/comm/left.jsp">
			<jsp:param name="first" value="rest"/>
			<jsp:param name="second" value="restStatDayManager"/>
		</jsp:include>
		<div class="c-right">
			<div class="panel panel-success">
				<div class="panel-heading">接口监控 / <b>今日接口请求信息</b></div>
				<div class="panel-body">
					<div class="row">
						<div class="col-sm-6">
						</div>
						<div class="col-sm-6 text-right">
						  	<div class="btn-group">
								<select id="refreshInterval" onchange="info.refreshChange()" class="form-control">
									<option value="">关闭自动刷新</option>
									<option value="5">5s刷新一次</option>
									<option value="10">10s刷新一次</option>
								</select>
						  	</div>
						  	<!-- <div class="btn-group">
						  		<a href="javascript:;" class="btn btn-success btn-sm" onclick="info.edit()">新增项目监控</a>
						  	</div> -->
						  	<div class="btn-group">
						  		<a href="javascript:location.reload()" class="btn btn-default btn-sm">刷新</a>
						  	</div>
						</div>
					</div>
				  	<hr/>
					<div id="infoPanel" style="overflow-x:scroll;"></div>
					<div id="infoPage"></div>
				</div>
			</div>
		</div>
		<br clear="all">
	</div>
	<jsp:include page="/WEB-INF/view/inc/footer.jsp"></jsp:include>
	<jsp:include page="/WEB-INF/view/inc/js.jsp"></jsp:include>
	<jsp:include page="/WEB-INF/view/inc/utils/page.jsp"></jsp:include>
<script type="text/javascript">
var infoPage = undefined;
var info = {
		//获取用户信息
		loadInfo : function(page) {
			if(!infoPage) {
				infoPage = new Page('infoPage', info.loadInfo, 'infoPanel', 'infoPage');
				infoPage.beginString = ['<table class="table table-striped table-hover" style="width: 1600px;"><thead><tr class="info">',
				                         '<th>服务地址</th>',
				                         '<th>URL</th>',
				                         '<th>总请求</th>',
				                         '<th>0点</th>',
				                         '<th>1点</th>',
				                         '<th>2点</th>',
				                         '<th>3点</th>',
				                         '<th>4点</th>',
				                         '<th>5点</th>',
				                         '<th>6点</th>',
				                         '<th>7点</th>',
				                         '<th>8点</th>',
				                         '<th>9点</th>',
				                         '<th>10点</th>',
				                         '<th>11点</th>',
				                         '<th>12点</th>',
				                         '<th>13点</th>',
				                         '<th>14点</th>',
				                         '<th>15点</th>',
				                         '<th>16点</th>',
				                         '<th>17点</th>',
				                         '<th>18点</th>',
				                         '<th>19点</th>',
				                         '<th>20点</th>',
				                         '<th>21点</th>',
				                         '<th>22点</th>',
				                         '<th>23点</th>',
				                         '<th width="100"></th>',
				                         '</tr></thead><tbody>'].join('');
				infoPage.endString = '</tbody></table>';
			}
			if(page != undefined)
				infoPage.page = page;
			var _statDate = JUtil.date.formatStr(JUtil.date.getDate(), 'yyyy-MM-dd');
			JUtil.ajax({
				url : '${webroot}/restStatDay/f-json/pageQuery.shtml',
				data : { page:infoPage.page, size:infoPage.size, statDate: _statDate },
				beforeSend: function(){ infoPage.beforeSend('加载信息中...'); },
				error : function(json){ infoPage.error('加载信息出错了!'); },
				success : function(json){
					if(json.code === 0) {
						function getResult(obj) {
							return ['<tr>',
							    	'<td>',obj.serverAddress,'</td>',
							    	'<td>',obj.url,'</td>',
							    	'<td>',obj.visitNum,'</td>',
							    	'<td>',info.formatNum(obj.hour0),'</td>',
							    	'<td>',info.formatNum(obj.hour1),'</td>',
							    	'<td>',info.formatNum(obj.hour2),'</td>',
							    	'<td>',info.formatNum(obj.hour3),'</td>',
							    	'<td>',info.formatNum(obj.hour4),'</td>',
							    	'<td>',info.formatNum(obj.hour5),'</td>',
							    	'<td>',info.formatNum(obj.hour6),'</td>',
							    	'<td>',info.formatNum(obj.hour7),'</td>',
							    	'<td>',info.formatNum(obj.hour8),'</td>',
							    	'<td>',info.formatNum(obj.hour9),'</td>',
							    	'<td>',info.formatNum(obj.hour10),'</td>',
							    	'<td>',info.formatNum(obj.hour11),'</td>',
							    	'<td>',info.formatNum(obj.hour12),'</td>',
							    	'<td>',info.formatNum(obj.hour13),'</td>',
							    	'<td>',info.formatNum(obj.hour14),'</td>',
							    	'<td>',info.formatNum(obj.hour15),'</td>',
							    	'<td>',info.formatNum(obj.hour16),'</td>',
							    	'<td>',info.formatNum(obj.hour17),'</td>',
							    	'<td>',info.formatNum(obj.hour18),'</td>',
							    	'<td>',info.formatNum(obj.hour19),'</td>',
							    	'<td>',info.formatNum(obj.hour20),'</td>',
							    	'<td>',info.formatNum(obj.hour21),'</td>',
							    	'<td>',info.formatNum(obj.hour22),'</td>',
							    	'<td>',info.formatNum(obj.hour23),'</td>',
							    	'<td></td>',
								'</tr>'].join('');
						}
						infoPage.operate(json.body, { resultFn:getResult, dataNull:'没有记录噢' });
					}
					else alert(JUtil.msg.ajaxErr);
				}
			});
		},
		//标色
		formatNum: function(num) {
			if(num === 0) {
				return ['<span class="text-muted">'+num+'</span>'].join('');
			}
			return ['<b class="text-success">'+num+'</b>'].join('');
		},
		refreshChange: function() {
			if(info.interval) {
				window.clearInterval(info.interval);
			}
			var _refresh = $('#refreshInterval').val();
			if(JUtil.isEmpty(_refresh)) {
				return;
			}
			info.interval = window.setInterval('info.loadInfo(1)', _refresh * 1000);
		}
};
$(function() {
	info.loadInfo(1);
});
</script>
</body>
</html>